#ifndef _MC_CONFIG_H__
#define _MC_CONFIG_H__

#include "os/types.h"
#include "math/fast_math.h"
#include "utils/utils.h"

typedef enum {
	pid_id,
	pid_iq,
	pid_vel,
	pid_max_id,
}pid_enum_t;

typedef struct
{
	u8 poles;
	float ld;
	float lq;
	float rs;
	float flux;
	float J;
	s16   max_rpm;
	float encoder_offset;
}motor_params_t;

typedef struct {
	s16 vbus_voltage_max;    //if higher than max, motor will force stop and can not start
	s16 vbus_voltage_min;    //if lower than min, motor will force stop and can not start
	s16 vbus_curr_max;
	s16 phase_curr_max;      //max phase current
}board_params_t;

typedef struct {
	float kp;
	float ki;
}pid_params_t;

typedef struct {	
	s16 	dq_loop_bandwith;
	s16     enc_pll_bandwith;
	pid_params_t pid[pid_max_id];
}contrl_params_t;

typedef struct {
	float pwm_freq;
	float ts;
	float slow_ts;
	u16   pwm_period;
	u16   pwm_half_period;
	motor_params_t m;
	board_params_t b;
	contrl_params_t c;
}mc_config_t;

extern mc_config_t _mc_conf;

void mc_conf_init(void);

static inline mc_config_t *mc_conf(void) {
	return &_mc_conf;
}

#endif /* _MC_CONFIG_H__ */

